#!/usr/bin/env bash
# author:yang
#
# 说明:使用该日志函数，需要先定义日志文件路径常量

# 该函数为内部函数，不建议直接调用。
function _logging() {
	
	local color_start=$1
	local color_end=$2
	local level=$3
	local message=$4
    [[ -f ${LOG_FILE} ]] && mv ${LOG_FILE} ${LOG_FILE}.`date +'%F-%H-%M-%S'`
	echo -e ${color_start}"[" `date +'%F %H:%M:%S'` "]" "[" $level "]" "msg:"$message${color_end}|tee -a ${LOG_FILE}
};

# info 级别日志信息打印
function log_info() {
	local color_start='\033[32m'
	local color_end='\033[0m'
	_logging  ${color_start} ${color_end} 'INFO' $1
};

# error 级别日志打印
function log_error() {
	local color_start='\033[31m'
	local color_end='\033[0m'
	_logging  ${color_start} ${color_end} 'ERROR' $1
};
